package com.typhoon.spring_shiro.dao;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.typhoon.spring_shiro.entity.User;

/**
 * 用户dao
 * 
 * @author Typhoon
 *
 */
@Repository("userDao")
public class UserDao extends BaseDao implements ICommonDao<User, Long> {

	private static final String TABLE_USER = "User";

	@Resource
	private JdbcTemplate financialJdbc;

	@Override
	public User queryByPrimaryKey(Long primaryKey) {
		return this.queryByPrimaryKey(financialJdbc, TABLE_USER, primaryKey, User.class);
	}

	@Override
	public int deleteByPrimaryKey(Long primaryKey) {
		return this.deleteByPrimaryKey(financialJdbc, TABLE_USER, "id", primaryKey);
	}

	@Override
	public User get(Object paramObject) {
		return this.get(financialJdbc, TABLE_USER, paramObject, User.class);
	}

	@Override
	public List<User> list(Map<String, Object> paramMap) {
		return this.list(financialJdbc, TABLE_USER, paramMap, User.class);
	}

	@Override
	public List<User> list(Object paramObject) {
		return this.list(financialJdbc, TABLE_USER, paramObject, User.class);
	}

	@Override
	public int update(User paramE) {
		return this.updateByPrimaryKey(financialJdbc, paramE, TABLE_USER);
	}

	@Override
	public long count(Map<String, Object> paramMap) {
		return this.count(financialJdbc, TABLE_USER, paramMap);
	}

	@Override
	public long count(Object paramObject) {
		return this.count(financialJdbc, TABLE_USER, paramObject);
	}

	@Override
	public User save(User paramE) {
		return this.addObjForKey(financialJdbc, TABLE_USER, paramE, "id");
	}

}
